﻿using System.Collections.Generic;
using System.Security.Claims;

namespace Sustainalytics.Claims
{
    public class ClaimComparer : IEqualityComparer<Claim>
    {
        public bool Equals(Claim claimA, Claim claimB)
        {
            string _claimA = claimA.Value.ToLowerInvariant() + ":" + claimA.Type.ToLowerInvariant();
            string _claimB = claimB.Value.ToLowerInvariant() + ":" + claimB.Type.ToLowerInvariant();

            bool result = _claimA.Equals(_claimB);

            return result;
        }

        public int GetHashCode(Claim claim)
        {
            string concat = claim.Value.ToLowerInvariant() + ":" + claim.Type.ToLowerInvariant();

            int value = concat.GetHashCode();

            return value;
        }
    }
}
